<include file="Public:header" />
    <h3 class="title"><em>邮件配置</em></h3>
	<div class="formbox">
    	<form name="mform" method="post" action="{:U('add')}">
		<table width="100%" border="0" cellspacing="1" cellpadding="0">
            <tr>
				<th>SMTP服务器地址：</th>
				<td><input name="smtp_host" type="text" class="ipt" id="smtp_host" size="30" maxlength="50" value="{$info['smtp_host']}" /><span class="tips">发送邮件的服务器地址，例smtp.126.com</span></td>
			</tr>
			<tr>
				<th>SMTP服务器端口：</th>
				<td><input name="smtp_port" type="text" class="ipt" id="smtp_port" size="10" maxlength="10" value="{$info['smtp_port']}" /><span class="tips">默认端口为25</span></td>
			</tr>
			<tr>
				<th>是否启用SMTP验证功能：</th>
				<td>
                <input name="smtp_auth" type="radio" id="smtp_auth1" value="yes" <eq name="info['smtp_auth']" value="yes">checked</eq>><label for="smtp_auth1">开启</label>&nbsp;
                <input name="smtp_auth" type="radio" id="smtp_auth0" value="no" <eq name="info['smtp_auth']" value="no">checked</eq>><label for="smtp_auth0">关闭</label><span class="tips">通常需要开启</span></td>
			</tr>
            <tr>
				<th>发件人：</th>
				<td><input name="smtp_from_name" type="text" class="ipt" id="smtp_from_name" size="30" maxlength="30" value="{$info['smtp_from_name']}" /><span class="tips">发送邮件的人</span></td>
			</tr>
			<tr>
				<th>SMTP服务器帐号：</th>
				<td><input name="smtp_user" type="text" class="ipt" id="smtp_user" size="30" maxlength="30" value="{$info['smtp_user']}" /><span class="tips">登录邮件服务器的帐号</span></td>
			</tr>
			<tr>
				<th>SMTP服务器密码：</th>
				<td><input name="smtp_pass" type="password" class="ipt" id="smtp_pass" size="30" maxlength="30" value="{$info['smtp_pass']}" /><span class="tips">登录邮件服务器的密码</span></td>
			</tr>
			<tr class="btnbox">
            	<th>&nbsp;</th>
				<td>
					<input type="submit" class="btn" value="保 存">&nbsp;
				</td>
			</tr>
            
            <tr>
				<th>接收邮箱：</th>
				<td><input type="text" class="ipt" id="smtp_test" size="30" maxlength="30" value="" /><input type="button" class="btn" value="测试发送" id="btn-smtp-test"><span class="tips">先保存,再来测试发送</span></td>
			</tr>
		</table>
        </form>
	</div>
<script type="text/javascript">
$(function(){
	$("#btn-smtp-test").click(function(){
		var smtpTestEmail = $("#smtp_test").val();
		if(smtpTestEmail == ''){
			alert('请输入接收测试邮件的邮箱地址!');
			return false;	
		}else{
			$("#btn-smtp-test").val("邮件发送中,请勿重复点击!");
			$.ajax({
			   type: "GET",
			   url: "{:U('testSendEmail')}",
			   data: "email="+smtpTestEmail,
			   success: function(result){
				   console.log(result);
					if(result['status'] == 1){
						$("#btn-smtp-test").val("发送成功!");
					}else{
						$("#btn-smtp-test").val("发送失败，换个邮箱再试试吧!");	
					}
			   }
			});	
		}
	});
});
</script>
<include file="Public:footer" />
